package com.lzc.springcloud.msconsumeruser;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.web.client.RestTemplate;

import com.lzc.springcloud.config.TestConfiguration;

@EnableEurekaClient
@SpringBootApplication
//@RibbonClient(name = "ms-eureka-provider-user-client", configuration = TestConfiguration.class) // 指定微服务访问的负载策略（方式一）
//@ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ANNOTATION, value = ExcludeFromComponentScan.class)})
public class Application {

	/**
	 * 要使用 RestTemplate，启动时需注入spring的bean中 
	 * LoadBalanced 使用负载均衡进行 http请求(默认负载均衡策略RoundRobin)
	 */
	@Bean
	@LoadBalanced // 使用负载均衡进行 http请求
	public RestTemplate restTemplate() {
		return new RestTemplate();
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}
